<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<meta name="referrer" content="no-referrer">
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的宠物</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #FFF9C4;
            color: #5D4037;
            line-height: 1.6;
        }

        /* 导航栏样式 */
        .navbar {
            background-color: white;
            padding: 0 5%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            height: 80px;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
            position: sticky;
            top: 0;
            z-index: 1000;
            border-bottom: 1px solid #FFECB3;
        }

        .nav-logo {
            color: #FFB300;
            font-size: 26px;
            font-weight: bold;
            display: flex;
            align-items: center;
        }

        .nav-logo i {
            margin-right: 12px;
            font-size: 30px;
        }

        .nav-links {
            display: flex;
            list-style: none;
        }

        .nav-links li {
            position: relative;
            margin: 0 10px;
        }

        .nav-links a {
            color: #5D4037;
            text-decoration: none;
            font-size: 16px;
            font-weight: 500;
            padding: 10px 18px;
            border-radius: 20px;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            min-width: 100px; /* 统一按钮最小宽度 */
            justify-content: center;
        }

        .nav-links a:hover {
            background-color: #FFF9C4;
            color: #FF8F00;
        }

        .nav-links a i {
            margin-right: 8px;
            color: #FFB300;
        }

        .dropdown {
            position: relative;
            display: inline-block;
        }

        .dropdown-content {
            display: none;
            position: absolute;
            background-color: white;
            min-width: 200px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.08);
            border-radius: 12px;
            z-index: 1;
            top: 100%;
            left: 0;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
            border: 1px solid #FFECB3;
            padding: 10px 0;
        }

        .dropdown:hover .dropdown-content {
            display: block;
            opacity: 1;
            transform: translateY(0);
        }

        .dropdown-content a {
            color: #5D4037;
            padding: 12px 20px;
            display: block;
            transition: all 0.2s;
            border-radius: 0;
        }

        .dropdown-content a:hover {
            background-color: #FFF9C4;
            color: #FF8F00;
            transform: none;
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: #FFF9C4;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            color: #FF8F00;
            font-weight: bold;
            font-size: 15px;
        }

        .login-btn {
            background-color: #FFF9C4;
            color: #FF8F00 !important;
        }

        .register-btn {
            background-color: #FFB300;
            color: white !important;
        }

        .register-btn:hover {
            background-color: #FF8F00 !important;
        }

        .logout-btn {
            background-color: #FFE0B2;
            color: #E65100 !important;
            border: 1px solid #FFCC80;
        }

        .logout-btn:hover {
            background-color: #FFCC80 !important;
        }
        /* 主要内容区域 */
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            margin-top: 80px;
        }

        /* 简化后的头部区域 */
        .page-header {
            text-align: center;
            padding: 30px 0;
            margin-bottom: 20px;
        }

        .page-header h1 {
            font-size: 2.8rem;
            color: #5D4037;
            margin-bottom: 10px;
            font-weight: 700;
            letter-spacing: 1px;
        }

        /* 宠物筛选区域 */
        .filters {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 15px;
            margin: 30px 0;
        }

        .filter-btn {
            background-color: #FFFDE7;
            border: 2px solid #FFD54F;
            border-radius: 50px;
            padding: 10px 25px;
            font-size: 1rem;
            cursor: pointer;
            transition: all 0.3s ease;
            color: #5D4037;
            font-weight: 600;
        }

        .filter-btn:hover, .filter-btn.active {
            background-color: #FFECB3;
            transform: translateY(-3px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        /* 宠物卡片区域 */
        .pets-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 30px;
            margin-top: 30px;
        }

        .pet-card {
            background: white;
            border-radius: 20px;
            overflow: hidden;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            border: 1px solid #FFECB3;
        }

        .pet-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
        }

        .pet-image {
            width: 100%;
            height: 250px;
            object-fit: cover;
            border-bottom: 4px solid #FFD54F;
        }

        .pet-info {
            padding: 22px;
        }

        .pet-name {
            font-size: 1.7rem;
            margin-bottom: 10px;
            color: #5D4037;
            font-weight: 600;
        }

        .pet-breed {
            display: inline-block;
            background-color: #FFF9C4;
            padding: 6px 16px;
            border-radius: 20px;
            font-size: 0.95rem;
            font-weight: 600;
            margin-bottom: 15px;
            color: #795548;
        }

        .pet-details {
            margin-bottom: 20px;
            color: #5D4037;
            font-size: 1rem;
        }

        .pet-details span {
            display: flex;
            align-items: center;
            margin: 8px 0;
        }

        .pet-details i {
            width: 24px;
            color: #FF9800;
            margin-right: 10px;
            font-size: 1.1rem;
        }

        .adopt-btn {
            display: block;
            width: 100%;
            padding: 12px;
            background: linear-gradient(to right, #FFB300, #FFA000);
            border: none;
            border-radius: 10px;
            color: white;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-align: center;
            text-decoration: none;
            margin-top: 10px;
        }

        .adopt-btn:hover {
            background: linear-gradient(to right, #FFA000, #FF8F00);
            transform: scale(1.02);
            box-shadow: 0 4px 12px rgba(255, 179, 0, 0.3);
        }

        footer {
            text-align: center;
            margin-top: 60px;
            padding: 30px;
            color: #795548;
            font-size: 0.95rem;
            border-top: 1px solid #FFECB3;
            background-color: rgba(255, 255, 255, 0.7);
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.4);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            border-radius: 10px;
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }

        @media (max-width: 768px) {
            .pets-container {
                grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            }

            .page-header h1 {
                font-size: 2.2rem;
            }

            .nav-links {
                display: none;
            }

            .navbar {
                padding: 0 20px;
                height: 70px;
            }
        }

        @media (max-width: 480px) {
            .filters {
                gap: 10px;
            }

            .filter-btn {
                padding: 8px 18px;
                font-size: 0.9rem;
            }

            .pet-card {
                border-radius: 15px;
            }

            .page-header h1 {
                font-size: 2rem;
            }
        }
        /* 添加宠物按钮样式 */
        #addPetBtn {
            background: linear-gradient(to right, #FFB300, #FFA000);
            color: white;
            border: none;
            padding: 12px 24px;
            font-size: 1.1rem;
            font-weight: 600;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 8px rgba(255, 179, 0, 0.2);
            margin-top: 20px;
        }

        #addPetBtn:hover {
            background: linear-gradient(to right, #FFA000, #FF8F00);
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(255, 179, 0, 0.3);
        }

        #addPetBtn:active {
            transform: translateY(0);
        }
        /* 模态框美化 */
        .modal-content {
            background-color: #fff;
            margin: 10% auto;
            padding: 30px;
            width: 50%;
            max-width: 500px;
            border-radius: 15px;
            box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
            position: relative;
            animation: modalopen 0.3s;
        }

        @keyframes modalopen {
            from {opacity: 0; transform: translateY(-50px);}
            to {opacity: 1; transform: translateY(0);}
        }

        .modal-content h2 {
            color: #5D4037;
            margin-bottom: 20px;
            text-align: center;
            font-size: 1.8rem;
        }

        .modal-content form {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .modal-content label {
            font-weight: 600;
            color: #5D4037;
            margin-bottom: -10px;
        }

        .modal-content input[type="text"],
        .modal-content input[type="number"] {
            padding: 12px 15px;
            border: 2px solid #FFECB3;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s;
            width: 100%;
        }

        .modal-content input[type="text"]:focus,
        .modal-content input[type="number"]:focus {
            border-color: #FFB300;
            outline: none;
            box-shadow: 0 0 0 3px rgba(255, 179, 0, 0.2);
        }

        .modal-content input[type="submit"] {
            background: linear-gradient(to right, #FFB300, #FFA000);
            color: white;
            border: none;
            padding: 12px;
            font-size: 1.1rem;
            font-weight: 600;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s;
            margin-top: 10px;
        }

        .modal-content input[type="submit"]:hover {
            background: linear-gradient(to right, #FFA000, #FF8F00);
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(255, 179, 0, 0.3);
        }

        .close {
            color: #aaa;
            position: absolute;
            top: 15px;
            right: 20px;
            font-size: 28px;
            font-weight: bold;
            transition: all 0.3s;
        }

        .close:hover,
        .close:focus {
            color: #FF8F00;
            text-decoration: none;
            cursor: pointer;
            transform: scale(1.2);
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .modal-content {
                width: 80%;
                padding: 20px;
            }
        }

        @media (max-width: 480px) {
            .modal-content {
                width: 95%;
            }
        }
    </style>
</head>
<body>
<!-- 导航栏 -->
<jsp:include page="head.jsp"/>

<!-- 主要内容区域 -->
<div class="container">
    <!-- 简化后的标题 -->
    <div class="page-header">
        <h1>我的宠物</h1>
        <button id="addPetBtn">添加宠物</button>
    </div>

    <!-- 筛选按钮 -->
    <%--    <div class="filters">--%>
    <%--        <button class="filter-btn active">全部</button>--%>
    <%--        <button class="filter-btn">狗狗</button>--%>
    <%--        <button class="filter-btn">猫咪</button>--%>
    <%--        <button class="filter-btn">小型宠物</button>--%>
    <%--        <button class="filter-btn">其他</button>--%>
    <%--    </div>--%>

    <!-- 宠物列表 -->
    <div class="pets-container">
        <c:forEach items="${petList}" var="pt">
            <div class="pet-card">
                <img src="${pt.photo_url}" class="pet-image">
                <div class="pet-info">
                    <h2 class="pet-name">${pt.name}</h2>
                    <div class="pet-breed">${pt.breed}</div>
                    <div class="pet-details">
                        <span><i class="fas fa-birthday-cake"></i>年龄: ${pt.age}</span>
                        <span><i class="fas fa-weight-hanging"></i>体重: ${pt.weight}kg</span>
                        <span><i class="fas fa-heartbeat"></i>健康: ${pt.health_status}</span>
                    </div>
                </div>
            </div>
        </c:forEach>
    </div>
</div>

<!-- 模态框 -->
<div id="myModal" class="modal">
    <div class="modal-content">
        <span class="close">&times;</span>
        <h2>添加宠物信息</h2>
        <form id="addPet" action="${pageContext.request.contextPath}/pet/add">
            <label for="petName">宠物名称:</label>
            <input type="text" id="petName" name="petName"><br>
            <label for="petType">宠物类型:</label>
            <input type="text" id="petType" name="petType"><br>
            <label for="petBreed">宠物品种:</label>
            <input type="text" id="petBreed" name="petBreed"><br>
            <label for="petAge">宠物年龄:</label>
            <input type="number" id="petAge" name="petAge"><br>
            <label for="petWeight">宠物体重:</label>
            <input type="number" step="0.01" id="petWeight" name="petWeight"><br>
            <label for="petPhotoUrl">宠物照片链接:</label>
            <input type="text" id="petPhotoUrl" name="petPhotoUrl"><br>
            <label for="petHealthStatus">宠物健康状况:</label>
            <input type="text" id="petHealthStatus" name="petHealthStatus"><br>
            <input type="submit" value="提交">
        </form>
    </div>
</div>

<footer>
    <div class="container">
        <p>© 2023 可爱宠物之家 | 领养代替购买</p>
        <p>电话: (123) 456-7890 | 邮箱: info@lovelypets.com</p>
    </div>
</footer>

<script>
    // 获取模态框
    var modal = document.getElementById("myModal");

    // 获取打开模态框的按钮
    var btn = document.getElementById("addPetBtn");

    // 获取关闭模态框的 <span> 元素
    var span = document.getElementsByClassName("close")[0];

    // 当用户点击按钮时，打开模态框
    btn.onclick = function() {
        modal.style.display = "block";
    }

    // 当用户点击 <span> (x) 时，关闭模态框
    span.onclick = function() {
        modal.style.display = "none";
    }

    // 当用户点击模态框之外的地方时，关闭模态框
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }

    // 筛选按钮交互效果
    document.querySelectorAll('.filter-btn').forEach(button => {
        button.addEventListener('click', function() {
            document.querySelectorAll('.filter-btn').forEach(btn => {
                btn.classList.remove('active');
            });
            this.classList.add('active');
        });
    });

    // 领养按钮点击效果
    document.querySelectorAll('.adopt-btn').forEach(button => {
        button.addEventListener('click', function(e) {
            e.preventDefault();
            const petName = this.closest('.pet-card').querySelector('.pet-name').textContent;
            alert(`感谢您考虑领养${petName}！我们的工作人员将很快联系您。`);
        });
    });

    // 表单提交事件
    document.getElementById("addPetForm").addEventListener("submit", function(event) {
        event.preventDefault();
        // 这里可以添加将表单数据发送到服务器的代码
        alert("宠物信息已提交！");
        modal.style.display = "none";
    });
</script>
</body>
</html>